import request from "@/utils/request";

const PLATFORMACCOUNT_BASE_URL = "/api/v1/platformAccounts";

const PlatformAccountAPI = {
  /** 获取账户明细分页数据 */
  getPage(queryParams?: PlatformAccountPageQuery) {
    return request<any, PageResult<PlatformAccountPageVO[]>>({
      url: `${PLATFORMACCOUNT_BASE_URL}/page`,
      method: "get",
      params: queryParams,
    });
  },
  /**
   * 获取账户明细表单数据
   *
   * @param id 账户明细ID
   * @returns 账户明细表单数据
   */
  getFormData(id: number) {
    return request<any, PlatformAccountForm>({
      url: `${PLATFORMACCOUNT_BASE_URL}/${id}/form`,
      method: "get",
    });
  },

  /** 添加账户明细*/
  add(data: PlatformAccountForm) {
    return request({
      url: `${PLATFORMACCOUNT_BASE_URL}`,
      method: "post",
      data: data,
    });
  },

  /**
   * 更新账户明细
   *
   * @param id 账户明细ID
   * @param data 账户明细表单数据
   */
  update(id: number, data: PlatformAccountForm) {
    return request({
      url: `${PLATFORMACCOUNT_BASE_URL}/${id}`,
      method: "put",
      data: data,
    });
  },

  /**
   * 批量删除账户明细，多个以英文逗号(,)分割
   *
   * @param ids 账户明细ID字符串，多个以英文逗号(,)分割
   */
  deleteByIds(ids: string) {
    return request({
      url: `${PLATFORMACCOUNT_BASE_URL}/${ids}`,
      method: "delete",
    });
  },
};

export default PlatformAccountAPI;

/** 账户明细分页查询参数 */
export interface PlatformAccountPageQuery extends PageQuery {
  ownerId?: number;
  platform?: string;
  remark?: string;
}

/** 账户明细表单对象 */
export interface PlatformAccountForm {
  id?: number;
  ownerId?: number;
  platform?: string;
  username?: string;
  password?: string;
  remark?: string;
  createTime?: Date;
  updateTime?: Date;
  /** 多张图片 */
  picUrls?: string;
}

/** 账户明细分页对象 */
export interface PlatformAccountPageVO {
  id?: number;
  ownerId?: number;
  platform?: string;
  username?: string;
  password?: string;
  remark?: string;
  createTime?: Date;
  updateTime?: Date;
  /** 多张图片 */
  picUrls?: string;
}
